import { mapGetters } from 'vuex';
import { getBasiqInstitutions, getBasiqUser } from '@/api/risk/basiq';

export default {
  data() {
    return {
      // 结构列表
      institutions: []
    };
  },

  computed: {
    ...mapGetters(['currentUser'])
  },

  created() {
    this.getBasiqUser();
    this.getBasiqInstitutions();
  },

  methods: {
    // getBasiqUser
    getBasiqUser() {
      return new Promise((resolve, reject) => {
        const {
 email, mobile,
          first_name: firstName,
          last_name: lastName
        } = this.currentUser;
        const data = {
          email,
          mobile: `+61${mobile}`,
          firstName,
          lastName
        };
        getBasiqUser(data)
          .then((data) => {
            resolve(data);
          })
          .catch((error) => {
            reject(data);
          });
      });
    },

    // getBasiqInstitutions
    getBasiqInstitutions() {
      return new Promise((resolve, reject) => {
        getBasiqInstitutions()
          .then((res) => {
            this.institutions = res.data;
            resolve(data);
          })
          .catch(((error) => {
            reject(error);
          }));
      });
    }
  }
};
